﻿<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<List<FileInfo>>" %>
<%@ Import Namespace="System.IO" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Upload Images/Files</title>
    <script type="text/javascript" src="/areas/admin/scripts/ckeditor/ckeditor.js"></script>
</head>
<body>           
    <form action="/Admin/Upload/Index" method="post" enctype="multipart/form-data">  
      <label for="file">Image filename:</label><br />
      <input type="file" name="file" id="file" /><br />

      <input id="CKEditorFuncNum" name="CKEditorFuncNum" type="hidden" value="<%: ViewData["CKEditorFuncNum"].ToString() %>" />
      <input id="CKEditor" name="CKEditor" type="hidden" value="<%: ViewData["CKEditor"].ToString() %>" />
      <input id="langCode" name="langCode" type="hidden" value="<%: ViewData["langCode"].ToString() %>" />

      <input type="submit" value="Upload" />
    </form>

    <hr />

    <%  if (Model.Count > 0)
        {
            foreach (FileInfo image in Model)
            {
                string CKEditorUrl = "/content/uploadimages/" + User.Identity.Name + "/" + image.Name;
                string imageUrl = "/admin/upload/images/" + image.Name;
                %>
                <a title="<%: image.Name %>" href="javascript:void(0);" 
                    onclick="window.opener.CKEDITOR.tools.callFunction(<%: ViewData["CKEditorFuncNum"] %>, '<%: CKEditorUrl %>', ''); window.close();">
                    <img src="<%: imageUrl %>" border="0" 
                        alt="<%: image.Name %>" width="50" height="50" />
                </a>     
    <%      }
       } %>
</body>
</html>
